package com.mutouren.common.web;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.math.NumberUtils;

import com.mutouren.common.entity.PageInfo;

public class ParsePageInfo {
	
	private final static int defaultPageIndex = 1;
	private final static int defaultPageSize = 5;
	
	public static PageInfo parse(HttpServletRequest request) {
		
		int pageIndex = NumberUtils.toInt(request.getParameter("pageIndex"), defaultPageIndex);
		int pageSize = NumberUtils.toInt(request.getParameter("pageSize"), defaultPageSize);
		
		return new PageInfo(pageIndex, pageSize);
	}
}
